import React, { Component } from 'react'
import { Layout } from 'antd'
import { Redirect } from "react-router-dom"
import LeftNav from "../../components/LeftNav"
import Routes from "../../components/Routes"
import MyHeader from '../../components/MyHeader'

const { Header, Footer, Sider, Content } = Layout


export default class Admin extends Component {
  render() {
    let token = localStorage.getItem('grain_token')
    if (!token) {
      return <Redirect to="/login"></Redirect>
    }
    return (
      <>
        <Layout style={{ height: '100%' }}>
          <Sider>
            {/* 路由导航 */}
            <LeftNav></LeftNav>
          </Sider>
          <Layout>
            <Header style={{ padding: 0, height: '80px',backgroundColor: '#f0f2f5' }}>
              <MyHeader />
            </Header>
            <Content style={{ margin: '15px', backgroundColor: '#fff', overflowY: 'auto' }}>
              {/* 路由站位 */}
              <Routes />
            </Content>
            <Footer style={{ textAlign: 'center', color: '#999', fontSize: '12px', backgroundColor: '#fff' }}>
              推荐使用谷歌浏览器，可以获得更佳的页面操作体验
            </Footer>
          </Layout>
        </Layout>
      </>
    )
  }
}
